//
//  Router.m
//  emergency
//
//  Created by 张润东 on 2020/1/16.
//  Copyright © 2020 张润东. All rights reserved.
//

#import "ZJRouter.h"
@implementation ZJRouter

+ (EasyBaseViewController*)routerFor:(NSString *)router properties:(nullable NSDictionary*)properties{
    NSString *vcClassStr = router;
    Class vcClass = NSClassFromString(vcClassStr);
    id vc = vcClass? [[vcClass alloc]init]:nil;
    if (vc && [vc isKindOfClass:[UIViewController class]]) {
        EasyBaseViewController *baseVC = vc;
        if (properties) {
            baseVC.routerParams =properties;
        }
        return  baseVC;
    }
    return nil;
}

+ (EasyBaseViewController*)routerForStoryboard:(NSString *)router properties:(nullable NSDictionary*)properties{
    NSString *vcClassStr = router;
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:vcClassStr bundle:nil];
    EasyBaseViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:vcClassStr];
    if (vc && [vc isKindOfClass:[UIViewController class]]) {
        EasyBaseViewController *baseVC = vc;
        if (properties) {
            baseVC.routerParams =properties;
        }
        return  baseVC;
    }
    return nil;
}

@end
